package ${toolsPackage};


import org.apache.commons.lang3.StringUtils;

import ${daoPackage}.${modular}.db.domain.${tableNameHump?cap_first};

public class ${tableNameHump?cap_first}Tools  {

 
	public static ${tableNameHump?cap_first} to${tableNameHump?cap_first}(${tableNameHump?cap_first} row){
		if(null == row){
			return null ;
		}
		${tableNameHump?cap_first} data = new ${tableNameHump?cap_first}() ;
		<#list columns as row>
			<#if  row.name == "id" >
				data.set${row.humpName?cap_first}(null);
			<#elseif row.name == "ctime" ||  row.name == "utime">
				data.set${row.humpName?cap_first}(java.time.LocalDateTime.now()) ;
			<#else>
				<#if row.javaType == "String" >
				if (StringUtils.isNotBlank( row.get${row.humpName?cap_first}())) {
					data.set${row.humpName?cap_first}(row.get${row.humpName?cap_first}().trim());
				}else{
					data.set${row.humpName?cap_first}("");
				}
				<#else>
				if (null != row.get${row.humpName?cap_first}()) {
					data.set${row.humpName?cap_first}(row.get${row.humpName?cap_first}());
				}
				</#if>
			</#if>
		</#list> 
		
		return data ;
	}



	public static ${tableNameHump?cap_first} to${tableNameHump?cap_first}View(${tableNameHump?cap_first} row){
		if(null == row){
			return null ;
		}
		${tableNameHump?cap_first} data = new ${tableNameHump?cap_first}() ;
		<#list columns as row>
			<#if  row.name == "id" >
				data.set${row.humpName?cap_first}(null);
			<#elseif row.name == "ctime" ||  row.name == "utime">
				data.set${row.humpName?cap_first}(java.time.LocalDateTime.now()) ;
			<#else>
				<#if row.javaType == "String" >
				if (StringUtils.isNotBlank(row.get${row.humpName?cap_first}())) {
					data.set${row.humpName?cap_first}(row.get${row.humpName?cap_first}().trim());
				}else{
					data.set${row.humpName?cap_first}("");
				}
				<#else>
				if (null != row.get${row.humpName?cap_first}()) {
					data.set${row.humpName?cap_first}(row.get${row.humpName?cap_first}());
				}
				</#if>
			</#if>
		</#list> 
		
		return data ;
	}
}
